package com.zzh.net.interceptor;

import java.io.IOException;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * http请求错误统计 接口异常上报
 *
 * @author jacen
 * @data 2019/12/16 17:17
 * @email jacen@iswsc.com
 */
public class HttpErrorRecordInterceptor implements Interceptor {
    private static final Charset UTF8 = Charset.forName("UTF-8");

    public enum Level {
        NONE,
        BASIC,
        HEADERS,
        BODY
    }

    public HttpErrorRecordInterceptor() {
    }

    private volatile Level level = Level.BODY;


    @Override
    public Response intercept(Chain chain) throws IOException {
        Level level = this.level;
        Request request = chain.request();
        String url = request.url().toString();

        if (level == Level.NONE) {
            return chain.proceed(request);
        }
        long startNs = System.nanoTime();
        Response response = chain.proceed(request);
        return response;
    }

    private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
}
